using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ShiptoMap : EntityTypeConfiguration<Shipto>
    {
        public ShiptoMap()
        {
            // Primary Key
            this.HasKey(t => t.SHIPPING_ID);

            // Properties
            this.Property(t => t.ID)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.DESC)
                .HasMaxLength(35);

            this.Property(t => t.COMPANY)
                .HasMaxLength(35);

            this.Property(t => t.ADDR1)
                .HasMaxLength(35);

            this.Property(t => t.ADDR2)
                .HasMaxLength(35);

            this.Property(t => t.CITY)
                .HasMaxLength(21);

            this.Property(t => t.STATE)
                .HasMaxLength(3);

            this.Property(t => t.ZIP)
                .HasMaxLength(14);

            this.Property(t => t.COMMENT1)
                .HasMaxLength(35);

            this.Property(t => t.COMMENT2)
                .HasMaxLength(35);

            this.Property(t => t.TAXAUTH)
                .HasMaxLength(15);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Shipto");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.COMPANY).HasColumnName("COMPANY");
            this.Property(t => t.ADDR1).HasColumnName("ADDR1");
            this.Property(t => t.ADDR2).HasColumnName("ADDR2");
            this.Property(t => t.CITY).HasColumnName("CITY");
            this.Property(t => t.STATE).HasColumnName("STATE");
            this.Property(t => t.ZIP).HasColumnName("ZIP");
            this.Property(t => t.COMMENT1).HasColumnName("COMMENT1");
            this.Property(t => t.COMMENT2).HasColumnName("COMMENT2");
            this.Property(t => t.TAXAUTH).HasColumnName("TAXAUTH");
            this.Property(t => t.SHIPPING_ID).HasColumnName("SHIPPING_ID");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasRequired(t => t.Cust)
                .WithMany(t => t.Shiptoes)
                .HasForeignKey(d => d.ID);

        }
    }
}
